import request from '@/utils/request'

//获取用户列表
export const getAllUser = (page = 1, size = 9) => {
  return request.get('/admin/allUser', {
    params: {
      page,
      size
    }
  })
}

//删除用户
export const deleteUserByid = (userId) => {
  return request.get(`/admin/deleteUserById/${userId}`)
}

//获取单个用户详情
export const getUserById = (userId) => {
  return request.get(`/admin/getUserById/${userId}`)
}

//提交修改
export const updateUser = (user) => {
  return request.post(`/admin/updateUser/${user.userId}`,user)
}

//获取学院班级列表
export const getCollegesWithClasses = () => {
  return request.get('/admin/getCollegesWithClasses')
}

//添加学院
export const addNewCollege = (name) => {
  return request.post('/admin/addCollege',name)
}

//添加班级
export const addNewClass = (data) =>{
  return request.post('/admin/addClass',data)
}

//修改班级
export const updateClassById = (classId,data) => {
  return request.post(`/admin/updateClassById/${classId}`,data)
}

//删除班级
export const deleteClassById = (classId) => {
  return request.get(`/admin/deleteClassById/${classId}`)
}

//获取项目列表
export const getProjectList = ()=> {
  return request.get('/admin/getProjectList')
}

//创建项目
export const addProject = (project) => {
  return request.post('/admin/addProject',project)
}

//删除项目
export const deleteProjectByid = (projectId) =>{
  return request.get(`/admin/deleteProjectByid/${projectId}`)
}

//修改项目
export const updateProjectById = (projectId,projectData)=> {
  return request.post(`/admin/updateProjectById/${projectId}`,projectData)
}

//修改project状态
export const updateStatusById = (projectId,data) => {
  return request.post(`/admin/updateStatusById/${projectId}`,data)
}

//获取项目信息列表
export const getProjectAndUser = () => {
  return request.get('/admin/getProjectAndUser')
}

//移出成员
export const deleteComUser = (userId,projectId) => {
  return request.get(`/admin/deleteComUser/${userId}/${projectId}`)
}
//移出裁判
export const deleteReferee = (userId,projectId) => {
  return request.get(`/admin/deleteReferee/${userId}/${projectId}`)
}

//移出团队成员
export const deleteTeamComUser = (userId,projectId) => {
  return request.get(`/admin/deleteTeamComUser/${userId}/${projectId}`)
}


//获取个人赛所有项目
export const getProjects=(type)=>{
  return request.get(`/admin/getProject/${type}`)
}

//通过projectId获取参赛人员(个人)
export const getPeople=(projectId)=>{
  return request.get(`/admin/getPeople/${projectId}`)
}

//通过projectId获取参赛人员(团体)
export const getTeam=(projectId)=>{
  return request.get(`/admin/getTeams/${projectId}`)
}

//比赛打分(个人)
export const setScore=(userId,arrangementId,score=null)=>{
  // 构建请求的URL
  let url = '/admin/setScore?userId=' + userId + '&arrangementId=' + arrangementId;
  // 如果score存在，则添加到URL中
  if (score !== null) {
    url += '&score=' + score;
  }
  return request.put(url)
}

//比赛打分（团队）
export const setScore2=(userId,arrangementId,score=null)=>{
  // 构建请求的URL
  let url = '/admin/setTeamScore?userId=' + userId + '&arrangementId=' + arrangementId;
  // 如果score存在，则添加到URL中
  if (score !== null) {
    url += '&score=' + score;
  }
  return request.put(url)
}

//获取成绩函数
export const getScore=(userId,arrangementId,type=null)=>{
  return request.get('/admin/getScore?userId='+userId+'&arrangementId='+arrangementId+'&type='+type)
}

//获取打分项目列表
export const getProjectsList = () => {
  return request.get('/admin/getProjectsList')
} 


